#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
int check_year(int year)
{
	if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
	{
		return 1;
	}
	else
	{
		return 0;
	}

}


int main(void)
{
	int year, month, day;
	int arr[2][12] = { {31,28,31,30,31,30,31,31,30,31,30,31},
		{31,29,31,30,31,30,31,31,30,31,30,31} };
	while (cin >> year >> month >> day)
	{
		int i = check_year(year);
		int con = 0;
		for (size_t j = 0; j < month - 1; j++)
		{
			con += arr[i][j];
		}
		con += day;
		cout << con << endl;
	}
	return 0;
}